package com.example.raising_skills.controller;


import com.example.common.PageUtils;
import com.example.common.dto.BaseReturnDto;
import com.example.raising_skills.entity.RaisingSkillsDO;
import com.example.raising_skills.service.RaisingSkillsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tc
 * @since 2022-10-30
 */
@RestController
@RequestMapping("/raisingSkillsDO")
public class RaisingSkillsController {
    @Autowired
    RaisingSkillsService raisingSkillsService;
    /*
     *添加
     */
    @GetMapping("/add")
    public BaseReturnDto<RaisingSkillsDO> add(
                                              @RequestParam("question")String question,
                                              @RequestParam(value = "varieties",required = false,defaultValue = "")String varieties,
                                              @RequestParam(value = "answer",required = false) String answer
    ){
        return raisingSkillsService.addSkills(varieties,question,answer);
    }
//    @GetMapping("/qury")
//    public BaseReturnDto<RaisingSkillsDO> qury(){
//        return  BaseReturnDto.success().msg("查询成功").data( raisingSkillsService.qurylist());
//    }
    @GetMapping("/query")
    public BaseReturnDto<?> query(@RequestParam (defaultValue = "1") Integer pageNum,
                                 @RequestParam (defaultValue = "4")Integer pageSize,
     @RequestParam(value = "search",required = false,defaultValue = "") String search){
        PageUtils page  = raisingSkillsService.querylist(pageNum,pageSize,search);
        return  BaseReturnDto.success().data(page);
    }
}

